// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import VirtualItem from "../../ui/VirtualItem";
import { VirtualArgs } from "../../ui/VirtualList";

const {ccclass, property} = cc._decorator;

export interface PlateItemArgs extends VirtualArgs {
    ts_code: string;
    name: string;
    type: string;
    stocks: any;
    weight: number;
    total: number;
    count: number;
}

@ccclass
export default class PlateInfoItem extends VirtualItem<PlateItemArgs> {

    @property(cc.Label)
    textLabel: cc.Label = null;

    stocks: any = null;

    public onRefresh(args: PlateItemArgs) {
        let strData = args.type;
        strData += '  ' + args.name;
        if (args.weight > 0) {
            strData += '  权重:' + args.weight;
        }
   
        strData += '  关联股数量：' + args.count;
        strData += '  成分股股数量：' + args.total;
        this.stocks = args.stocks;
        this.textLabel.string = strData;
    }

    onClick () {
        cc.director.emit('PlateItemClickEvent', this.stocks);
    }

    // update (dt) {}
}
